<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>view/workArea/parts/selectFse</title>
		<!-- css代码 start -->
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../css/global.css" rel="stylesheet" />
		<link href="../../../css/style.css" rel="stylesheet" />
		<link href="../../../css/checkbox.css" rel="stylesheet" />
		<style>
			.mui-radio input[type=radio]{
				left: 0;
				top: 11px;
			}
			.mui-checkbox label, .mui-radio label{
				padding-left: 38px;
				font-size: 14px;
				color: #333333;
				padding-right: 0;
			}
		</style>
		<!-- css代码 end -->
	</head>
	<body>
		<!-- html代码 start -->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">选择工程师</h1>
		</header>
		<div class="mui-content">

			<div class="page_cen shadow zp_cen">
				<div class="zp_sear autoHeight">
					<button class="btn" id="chaxun" onclick="getTeamleaderList()"></button>
					<div class="iptBox">
						<input type="text" id="enginnerName" placeholder="请输入工程师名称" />
					</div>
				</div>
				<div class="jy_clum" id="qtTl">
				</div>
			</div>
			<div class="btn_box">
				<span class="fl red one" id="confirmBtn">确认</span>
			</div>
		</div>
		<!-- html代码 end -->

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">
			(function($, doc) {
				$.init();

				$.plusReady(function() {
					// 从上一个页面取值
					var self = plus.webview.currentWebview();
					// 查询所有fse
					getTeamleaderList(app.getUser().enginnerId);
					// 确认转移
					h("#confirmBtn").tap(function(){
						var fseId = "";
						var fseName = "";
						var ele = document.getElementsByName("checkbox1");
						for (var i = 0; i < ele.length; i++) {	
							if(ele[i].checked){
								fseId = ele[i].value;
								fseName = ele[i].getAttribute("fseName");
								break
							}
						}
						
						var parent = plus.webview.getWebviewById('view/workArea/parts/transferParts');
						if(parent){
							mui.fire(parent, 'customEvent', {"fseId":fseId, "fseName":fseName});
						}
						var parent1 = plus.webview.getWebviewById('view/workArea/parts/searchPartsTl');	
						if(parent1){
							mui.fire(parent1, 'customEvent', {"fseId":fseId, "fseName":fseName});
						}			
						self.close();
					})
				});

			}(mui, document));

			// 查询所有fse
			function getTeamleaderList(eid) {
				app.showWaiting('加载中...')
				ajaxPost(BASE_URL + "cc/engineerManage/selectTransferFse", {
					// "teamleaderId": app.getUser().teamleaderId,
					"enginnerId": eid?eid:'',
					"enginnerName": h("#enginnerName").val()
				}, function(data) {
					console.log(JSON.stringify(data));
					if (data.code == 200) { //查询成功
						app.closeWaiting()
						var html = "";
						if (data.data.length == 0) {
							html = '<div class="nodata">—— 暂无数据 ——</div>';
							h("#qtTl").html(html);
						} else {
							for (var i = 0; i < data.data.length; i++) {
								var das = data.data[i];
								var fseId = das.enginner_id
								var fseName = das.NAME;
								html += '<div class="mui-input-row mui-radio">'
								html += '<input name="checkbox1" value="' + fseId + '" fseName="'+fseName+'" type="radio" class="rds"/> '
								html += '<label>' + fseName + '</label> '
								html += '</div>';
							}
							h("#qtTl").html(html);
						}
					} else { //查询失败
						app.closeWaiting()
						var html = '<div class="nodata">—— 暂无数据 ——</div>';
						h("#qtTl").html(html);
						app.toast("查询失败");
					}
				}, function(errorMsg) {
					app.closeWaiting()
					var html = '<div class="nodata">—— 暂无数据 ——</div>';
					h("#qtTl").html(html);
					app.toast("数据获取失败，请检查网络连接");
				});
			}


		</script>
		<!-- js代码 end -->
	</body>
</html>
